package com.fjd.mapper;

import com.fjd.entity.AfterSale;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AfterSaleMapper {
    @Select("select * from aftersales")
    List<AfterSale> list();

    @Select("select * from aftersales where id = #{id}")
    AfterSale findById(String id);

    @Insert("INSERT INTO aftersales (id, order_id, reason, reason_detail, aftersales_state, generate_time, type,note,amount) " +
            "VALUES (#{id}, #{orderId}, #{reason}, #{reasonDetail}, #{aftersalesState}, #{generateTime}, #{type},#{note},#{amount})")
    void insertAfterSale(AfterSale afterSale);

    @Update("UPDATE aftersales " +
            "SET aftersales_state = #{aftersalesState}, note = #{note} " +  // 注意空格
            "WHERE id = #{id}")
    void updateAftersalesState(@Param("id") String id, @Param("aftersalesState") String aftersalesState,@Param("note") String note);

    @Delete("DELETE from aftersales where id=#{id}")
    void deleteAfterSale(String id);

}
